#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
USER app
WORKDIR /app
EXPOSE 8080

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["J.M.Inventory.Read.API/J.M.Inventory.Read.API.csproj", "J.M.Inventory.Read.API/"]
COPY ["A.M.RabbitMQ/A.M.RabbitMQ.csproj", "A.M.RabbitMQ/"]
COPY ["Attribute_Extension/Attribute_Extension.csproj", "Attribute_Extension/"]
COPY ["ConsulUIlity/ConsulUIlity.csproj", "ConsulUIlity/"]
COPY ["J.M.Inventory.Application/J.M.Inventory.Application.csproj", "J.M.Inventory.Application/"]
COPY ["A.M.Storage.Application/A.M.Storages.Services.csproj", "A.M.Storage.Application/"]
COPY ["A.M.Storage.I_Application/A.M.Storages.IServices.csproj", "A.M.Storage.I_Application/"]
COPY ["A.M.ETO/A.M.ETO.csproj", "A.M.ETO/"]
COPY ["A.M.Storage.I_Infrastruecure/A.M.Storages.IRepository.csproj", "A.M.Storage.I_Infrastruecure/"]
COPY ["J.M.Inventory.Domain/J.M.Inventory.Domain.csproj", "J.M.Inventory.Domain/"]
COPY ["J.M.Inventory.Infrastruecure/J.M.Inventory.Infrastruecure.csproj", "J.M.Inventory.Infrastruecure/"]
COPY ["A.M.Storage.Infrastruecure/A.M.Storage.Repository.csproj", "A.M.Storage.Infrastruecure/"]
COPY ["Public_Class_Library/Public_Class_Library.csproj", "Public_Class_Library/"]
COPY ["Q.M.Sell.Doamin/Q.M.Sell.Doamin.csproj", "Q.M.Sell.Doamin/"]
COPY ["Redis_ClientInfor/Redis_ClientInfor.csproj", "Redis_ClientInfor/"]
COPY ["Linked_Database/Linked_Database.csproj", "Linked_Database/"]
COPY ["O.M.Production.Domain/O.M.Production.Domain.csproj", "O.M.Production.Domain/"]
COPY ["O.M.Production.ErrorCodeEnum/O.M.Production.ErrorCodeEnum.csproj", "O.M.Production.ErrorCodeEnum/"]
RUN dotnet restore "./J.M.Inventory.Read.API/J.M.Inventory.Read.API.csproj"
COPY . .
WORKDIR "/src/J.M.Inventory.Read.API"
RUN dotnet build "./J.M.Inventory.Read.API.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./J.M.Inventory.Read.API.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "J.M.Inventory.Read.API.dll"]